import { AxiosResponse } from 'axios';
import request from '/@/utils/request';
const serverContextPath = '/admin'
// 定义接口来定义对象的类型
interface PageUtilsReturn {
	code: number
	msg: string
	page: {
		totalCount: number
		pageSize: number
		totalPage: number
		currPage: number
		list: Array<any>
	}
}

export function systemApi() {
	return {
		/**
		 * 验证码地址
		 * @param uuid 
		 * @returns 
		 */
		getCaptchaPath: (uuid: string) => {
			return import.meta.env.VITE_API_URL + serverContextPath + `/sys/login/captcha.jpg?uuid=${uuid}`
		},
		/**
		 * 登录
		 * @param username 用户名
		 * @param password 密码
		 * @param uuid 验证码校验码
		 * @param captcha 验证码
		 * @param terminal 终端pc-1 app-2
		 * @param tenantId 租户编号
		 * @returns 
		 */
		login: (username: string, password: string, uuid: string, captcha: string, terminal: string, tenantId: string) => {
			return request({
				url: serverContextPath + '/sys/login/login',
				method: 'post',
				data: {
					'username': username,
					'password': password,
					'uuid': uuid,
					'captcha': captcha,
					'terminal': terminal,
					'tenantId': tenantId
				}
			})
		},
		/**
		 * 解锁
		 * @param username 
		 * @param password 
		 * @param uuid 
		 * @param captcha 
		 * @param terminal 
		 * @returns 
		 */
		unblock: (username: string, password: string, uuid: string, captcha: string, terminal: string) => {
			return request({
				url: serverContextPath + '/sys/login/unblock',
				method: 'post',
				data: {
					'username': username,
					'password': password,
					'uuid': uuid,
					'captcha': captcha,
					'terminal': terminal
				}
			})
		},
		/**
		 * 
		 * @returns 登出
		 */
		logout: () => {
			return request({
				url: serverContextPath + '/sys/login/logout',
				method: 'post',
			})
		},
		/**
		 * 获取机构树（全集）返回方式
		 * @returns 
		 */
		getOrgsAsync: async () => {
			return request({
				url: serverContextPath + '/sys/org/treeList/',
				method: 'get',
			})
		},
		getOrgsByTenantId: (tenantId: string) => {
			return request({
				url: serverContextPath + '/sys/org/treeList/' + tenantId,
				method: 'get',
			})
		},
		getOrgsByTenantIdEl: (tenantId: string) => {
			return request({
				url: serverContextPath + '/sys/org/treeListEltree/' + tenantId,
				method: 'get',
			})
		},
		getOrgTreeList: () => {
			return request({
				url: serverContextPath + '/sys/org/treeList',
				method: 'get',
			})
		},
		/**
		 * 根据id删除机构
		 * @param id 机构id(主键)
		 * @returns 
		 */
		deleteOrgById: async (id: string) => {
			return request({
				url: serverContextPath + '/sys/org/deleteById',
				method: 'post',
				data: { 'id': id }
			})
		},
		/**
		 * 保存机构数据
		 * @param data 
		 * @returns 
		 */
		saveOrg: (data: any) => {
			return request({
				url: serverContextPath + '/sys/org/save',
				method: 'post',
				data: data
			})
		},
		/**
		 * 分页查询岗位信息
		 * @param params 
		 * @returns 
		 */
		queryStationList: async (params: any) => {
			return request({
				url: serverContextPath + '/sys/station/queryList',
				method: 'post',
				data: params
			})
		},
		/**
		 * 根据id查询岗位信息
		 * @param id 
		 * @returns 
		 */
		getStationInfo: (id: string) => {
			return request({
				url: serverContextPath + `/sys/station/info/${id}`,
				method: 'get',
			})
		},
		/**
		 * 获取资岗位源树，当前人员有权限的资源树或者自己租户的资源
		 * @param id 
		 * @returns 
		 */
		getResTree: (id: string) => {
			return request({
				url: serverContextPath + '/sys/station/getResTree',
				method: 'post',
				params: {
					'id': id || ''
				}
			})
		},
		/**
		 * 批量删除岗位
		 * @param ids 
		 * @returns 
		 */
		deleteStation: (ids: string[]) => {
			return request({
				url: serverContextPath + '/sys/station/delete',
				method: 'post',
				data: ids
			})
		},
		/**
		 * 批量删除岗位的资源权限
		 * @param ids 
		 * @returns 
		 */
		deleteStationRes: (ids: string[]) => {
			return request({
				url: serverContextPath + '/sys/station/deleteStationRes',
				method: 'post',
				data: ids
			})
		},
		/**
		 * 保存岗位信息
		 * @param data 
		 * @returns 
		 */
		saveStation: (data: any) => {
			return request({
				url: serverContextPath + '/sys/station/save',
				method: 'post',
				data: data
			})
		},
		/**
		 * 保存岗位资源权限
		 * @param id 
		 * @param resId 
		 * @returns 
		 */
		saveStationRes: (id: string, resId: any) => {
			return request({
				url: serverContextPath + '/sys/station/saveStationRes',
				method: 'post',
				data: {
					'id': id,
					'resId': resId
				}
			})
		},
		/**
		 * 获取机构岗位树形
		 * @param tenantId 
		 * @returns 
		 */
		getTreeStationList: (tenantId: string) => {
			return request({
				url: serverContextPath + '/sys/station/treeStationList/' + tenantId,
				method: 'get',
			})
		},
		/**
		 * 获取资岗位源树，当前人员有权限的资源树或者自己租户的资源
		 * @param tenantId 租户id
		 * @param id 岗位id
		 * @returns {Promise<*>} data.tree 资源树，data.asingRes 选择节点
		 */
		getTenantStationResTree: async (tenantId: string, id: string) => {
			return request({
				url: serverContextPath + '/sys/station/getTenantStationResTree',
				method: 'post',
				params: {
					'tenantId': tenantId,
					'id': id || ''
				}
			})
		},
		/**
		 * 数据字典分页查询
		 * @param params 
		 * @returns 
		 */
		getDicList: (params: any) => {
			return request({
				url: serverContextPath + '/sys/dic/list',
				method: 'post',
				data: params
			})
		},
		/**
		 * 根据字典编号取字典数据
		 * @param classCode 
		 * @returns 
		 */
		getDiclistByClassCode: (classCode: string) => {
			return request({
				url: serverContextPath + '/sys/dic/getDiclist/' + classCode,
				method: 'get',
			})
		},
		/**
		 * 获取所有数据字典
		 * @returns 
		 */
		getDicListAll: () => {
			return request({
				url: serverContextPath + '/sys/dic/getDiclistAll',
				method: 'get',
			})
		},
		/**
		 * 根据id获取字典数据
		 * @param id 
		 * @returns 
		 */
		getDicInfoById: (id: string) => {
			return request({
				url: serverContextPath + '/sys/dic/info/' + id,
				method: 'get',
			})
		},
		/**
		 * 保存数据字典
		 * @param data 
		 * @returns 
		 */
		saveDic: (data: any) => {
			return request({
				url: serverContextPath + '/sys/dic/save',
				method: 'post',
				data: data
			})
		},
		/**
		 * 修改数据字典
		 * @param data this.$http.adornData({
						'id': this.dataForm.id || undefined,
						'classCode': this.dataForm.classCode,
						'className': this.dataForm.className,
						'dataCode': this.dataForm.dataCode,
						'dataName': this.dataForm.dataName,
						'dataOrder': this.dataForm.dataOrder,
						'state': this.dataForm.state
					})
		* @returns {Promise<*>}
		*/
		updateDic: (data: any) => {
			return request({
				url: serverContextPath + '/sys/dic/update',
				method: 'post',
				data: data
			})
		},

		/**
		 * 删除数据字典
		 * @param ids 选中的id数组 var ids = id ? [id] : this.dataListSelections.map(item => {
				 return item.id
				})
		* @returns {Promise<*>}
		*/
		deleteDic: (ids: string[]) => {
			return request({
				url: serverContextPath + '/sys/dic/delete',
				method: 'post',
				data: ids
			})
		},

		/**
		 * 根据字典编码获取字典数据
		 * @param classCode 
		 * @returns [{"label": "check 1","value": 1},{"label": "check 2","value": 2}]
		 */
		getDicMapByclassCode: (classCode: string) => {
			return request({
				url: serverContextPath + '/sys/dic/getDicMapByclassCode' + classCode,
				method: 'get'
			})
		},
		/**
		 * 加载初始化菜单
		 * @returns {Promise<*>} data.menuList data.permissions
		 */
		nav: () => {
			return request({
				url: serverContextPath + '/sys/userAuth/navByTerminalRoute/' + 1,
				method: 'get',
			})
		},
		/**
		 * 当前用户的常用功能菜单
		 * @returns {Promise<*>} data.commUseMenu
		 */
		getCommUseMenuTree: (params: string) => {
			return request({
				url: serverContextPath + '/sys/userAuth/getCommUseMenuTreeByTerminal/' + params,
				method: 'get',
			})
		},
		/**
		 * 导航菜单,常用菜单选择树
		 * @returns {Promise<*>} data.menuList data.menucheckList
		 */
		getCommUseMenuSetTree: (params: string) => {
			return request({
				url: serverContextPath + '/sys/userAuth/getCommUseMenuSetTree/' + params,
				method: 'get',
			})
		},

		/**
		 * 当前用户的顶级菜单
		 * @returns {Promise<*>} data.topLevelmenuList data.msgNum
		 */
		navTopLevel: () => {
			return request({
				url: serverContextPath + '/sys/menu/navTopLevel',
				method: 'get',
			})
		},

		/**
		 * 所有菜单列表
		 * @returns {Promise<*>}
		 */
		getMenuList: (params: any) => {
			return request({
				url: serverContextPath + '/sys/menu/list',
				method: 'post',
				data: params
			})
		},

		/**
		 * 所有选择菜单列表
		 * @returns {Promise<*>}
		 */
		getMenuSelectList: () => {
			return request({
				url: serverContextPath + '/sys/menu/select',
				method: 'get',
			})
		},

		/**
		 * 所有选择菜单列表
		 */
		getMenuSelectListNoRoot: () => {
			return request({
				url: serverContextPath + '/sys/menu/selectNoRoot',
				method: 'get',
			})
		},

		/**
		 * 根据id获取菜单信息
		 * @param menuId
		 * @returns {Promise<*>}
		 */
		getMenuInfo: (menuId: string) => {
			return request({
				url: serverContextPath + '/sys/menu/info/' + menuId,
				method: 'get',
			})
		},

		/**
		 * 保存菜单数据
		 * @param data this.$http.adornData({
						'id': this.dataForm.id || undefined,
						'type': this.dataForm.type,
						'name': this.dataForm.name,
						'parentId': this.dataForm.parentId,
						'url': this.dataForm.url,
						'perms': this.dataForm.perms,
						'orderNum': this.dataForm.orderNum,
						'icon': this.dataForm.icon,
						'sysResource': this.dataForm.sysResource
					  })
		 * @returns {Promise<*>}
		 */
		saveMenuInfo: (data: any) => {
			return request({
				url: serverContextPath + '/sys/menu/save',
				method: 'post',
				data: data
			})
		},

		/**
		 * 修改菜单数据
		 * @param data this.$http.adornData({
						'id': this.dataForm.id || undefined,
						'type': this.dataForm.type,
						'name': this.dataForm.name,
						'parentId': this.dataForm.parentId,
						'url': this.dataForm.url,
						'perms': this.dataForm.perms,
						'orderNum': this.dataForm.orderNum,
						'icon': this.dataForm.icon,
						'sysResource': this.dataForm.sysResource
					  })
		 * @returns {Promise<*>}
		 */
		updateMenuInfo: (data: any) => {
			return request({
				url: serverContextPath + '/sys/menu/update',
				method: 'post',
				data: data
			})
		},

		/**
		 * 删除资源
		 * @param id 菜单id
		 * @returns {Promise<*>}
		 */
		deleteMenuInfo: (id: string) => {
			return request({
				url: serverContextPath + '/sys/menu/delete/' + id,
				method: 'post'
			})
		},
		/**
		 * 设置常用菜单
		 * @param ids 菜单id数组 this.$refs.restree.getCheckedKeys()
		 * @returns {Promise<*>}
		 */
		saveCommUseMenu: (ids: string[]) => {
			return request({
				url: serverContextPath + '/sys/userAuth/saveCommUseMenu',
				method: 'post',
				data: {
					'ids': ids
				}
			})
		},

		/**
		 * 记录用户菜单点击行为
		 * @param menuId 菜单id
		 * @returns {Promise<*>}
		 */
		menuClick: (menuId: string) => {
			return request({
				url: serverContextPath + '/sys/menu/menuClick/' + menuId,
				method: 'get',
			})
		},

		/**
		 * 查询用户,非超级管理员只能查询自己租户下用户
		 * @param params this.$http.adornParams({
				  page: this.pageIndex, 要请求的页
				  limit: this.pageSize, 每页条数
				  dataForm: this.dataForm 查询条件表单数据
				})
		 * @returns {Promise<*>} data.page
		 */
		queryUserListCouncil: (params: any) => {
			return request({
				url: serverContextPath + '/sys/user/list',
				method: 'post',
				data: params
			})
		},
		/**
		 * 查询编码
		 * @param params this.$http.adornParams({
					'page': pageIndex,要请求的页
					'limit':pageSize,每页条数
					'code': this.dataForm.code, 编码编号
					'name': this.dataForm.name 编码名称
				})
		 * @returns {Promise<*>} data.page
		 */
		queryDataDictionaryList: (params: any) => {
			return request({
				url: serverContextPath + '/sys/codeDef/list',
				method: 'get',
				params: params
			})
		},
		/**
		 * 根据id删除编码
		 */
		delectCodeDefInfo: (ids: string[]) => {
			return request({
				url: serverContextPath + '/sys/codeDef/delete',
				method: 'post',
				data: ids
			})
		},
		/**
		 * 根据id查询编码信息
		 */
		getCodeDefInfoById: (ids: string) => {
			return request({
				url: serverContextPath + `/sys/codeDef/info/${ids}`,
				method: 'get',
			})
		},
		/**
		 * 新增编码信息
		 */
		addCodeDefInfo: (data: any) => {
			return request({
				url: serverContextPath + `/sys/codeDef/addCodeDef`,
				method: 'post',
				data: data
			})
		},
		/**
		 * 修改编码信息
		 */
		upDateCodeDefInfo: (data: any) => {
			return request({
				url: serverContextPath + `/sys/codeDef/update`,
				method: 'post',
				data: data
			})
		},
		/**
		 * 编码规则列表
		 *
		*/
		queryCodeRulesList: (data: any) => {
			return request({
				url: serverContextPath + '/sys/codeUseInfo/list',
				method: 'get',
				params: data
			})
		},

		/**
		 * 获取编码编号 回收编码编号
		 * @param params http.adornParams({
						'code': this.dataForm.code,
						'param': this.dataForm.param,
						'codes': this.dataForm.codes,
						'num': this.dataForm.num,
						'op': 'getOne'    获取单条
							  'getBatch'  获取多条
							  'setOne'    回收单条
							  'setBatch'  批量回收
					  })
		 */
		codeTextOperation: (params: any) => {
			return request({
				url: serverContextPath + `/sys/codeUseInfo/codeTest`,
				method: 'post',
				params: params
			})
		},

		/**
		 * 根据id查询编码规则列表
		 */
		getCodeRulesList: (data: any) => {
			return request({
				url: serverContextPath + '/sys/codeRule/list',
				method: 'get',
				params: data
			})
		},
		/**
		 * 新增编码规则信息
		 */
		addCodeDefInfoById: (codeId: string) => {
			return request({
				url: serverContextPath + `/sys/codeDef/info/${codeId}`,
				method: 'get',
			})
		},
		/**
		 * 修改编码规则信息
		 */
		upDateCodeRuleInfo: (ids: string) => {
			return request({
				url: serverContextPath + `/sys/codeRule/info/${ids}`,
				method: 'get',
			})
		},
		/**
		 * 删除编码规则
		 */
		deleteCodeDefInfo: (ids: string[]) => {
			return request({
				url: serverContextPath + '/sys/codeRule/delete',
				method: 'post',
				data: ids
			})
		},
		/**
		 * 保存编码规则
		 */
		saveCodeDef: (data: any) => {
			return request({
				url: serverContextPath + `/sys/codeRule/addCodeRule`,
				method: 'post',
				data: data
			}).then(res => res)
		},
		/**
		 * 修改编码规则
		 */
		updateCodeDef: (data: any) => {
			return request({
				url: serverContextPath + `/sys/codeRule/update`,
				method: 'post',
				data: data
			}).then(res => res)
		},

		/**
		 * 获取登录的用户信息
		 * @returns {*} data.user
		 */
		getUserInfoSession: () => {
			return request({
				url: serverContextPath + '/sys/userAuth/info',
				method: 'get',
			})
		},

		/**
		 * 修改密码
		 * @param data this.$http.adornData({
						'password': this.dataForm.password,
						'newPassword': this.dataForm.newPassword
					  })
		 * @returns {*}
		 */
		password: (data: any) => {
			return request({
				url: serverContextPath + '/sys/user/password',
				method: 'post',
				data: data
			})
		},

		/**
		 * 根据用户id获取用户信息
		 * @returns {*} data.user用户基本信息
		 */
		getAllUserByTenantId: () => {
			return request({
				url: serverContextPath + '/sys/user/getAllUserByTenantId/',
				method: 'get',
				
			})
		},

		/**
		 * 根据用户id获取用户信息
		 * @param userId
		 * @returns {*} data.user用户基本信息
		 */
		getUserInfoById: (userId: string) => {
			return request({
				url: serverContextPath + '/sys/user/info/' + userId,
				method: 'get',
			})
		},

		/**
		 * 根据用户id获取用户信息
		 * @param userId
		 * @returns {*} data.stationList用户岗位信息
		 */
		getUserStationList: (userId: string) => {
			return request({
				url: serverContextPath + '/sys/user/getUserStationList/' + userId,
				method: 'get',
			})
		},

		/**
		 * 根据msgId获取用户信息
		 * @param msgId
		 * @returns {*} data.user用户基本信息 data.stationList岗位列表
		 */
		getMsgStationById: (msgId: string) => {
			return request({
				url: serverContextPath + '/sys/msgDef/getMsgStationById/' + msgId,
				method: 'get',
			})
		},

		/**
		 * 保存用户
		 * @param user 表单数据this.dataForm
		 * @param stationList 选中的岗位this.$refs.stationtree.getCheckedNodes()
		 * @returns {*}
		 */
		saveUserInfo: (dataForm: any, stationList: any) => {
			return request({
				url: serverContextPath + '/sys/user/save',
				method: 'post',
				data: {
					'user': dataForm,
					'stationList': stationList
				}
			})
		},

		/**
		 * 修改用户
		 * @param user 表单数据this.dataForm
		 * @param stationList 选中的岗位this.$refs.stationtree.getCheckedNodes()
		 * @returns {*}
		 */
		updateUserInfo: (dataForm: any, stationList: any) => {
			return request({
				url: serverContextPath + '/sys/user/update',
				method: 'post',
				data: {
					'user': dataForm,
					'stationList': stationList
				}
			})
		},
		/**
		 * 设置岗位消息
		 * @param msgDefId 用户id
		 * @param stationList 岗位树选择的数组
		 * @returns {*}
		 */
		setMsgStation: (msgDefId: any, stationList: any) => {
			return request({
				url: serverContextPath + '/sys/msgDef/setMsgStation',
				method: 'post',
				data: {
					'msgDefId': msgDefId,
					'stationList': stationList
				}
			})
		},
		/**
		 * 设置用户岗位
		 * @param userId 用户id
		 * @param stationList 岗位树选择的数组
		 * @returns {*}
		 */
		setUserStation: (userId: any, stationList: any) => {
			return request({
				url: serverContextPath + '/sys/user/setUserStation',
				method: 'post',
				data: {
					'userId': userId,
					'stationList': stationList
				}
			})
		},
		/**
		 * 查询用户资源权限
		 * @param {租户id} tenantId 
		 * @param {用户id} id 
		 */
		getTenantUserResTree: (tenantId: string, id: string) => {
			return request({
				url: serverContextPath + '/sys/user/getTenantUserResTree/' + tenantId + "/" + id,
				method: 'get',
			})
		},

		/**
		 * 设置用户资源
		 * @param id 用户id
		 * @param resId 资源id数组
		 * @returns {*}
		 */
		setSysUserMenu: (id: any, resId: any) => {
			return request({
				url: serverContextPath + `/sys/user/setSysUserMenu`,
				method: 'post',
				data: {
					'id': id,
					'resId': resId
				}
			})
		},

		/**
		 * 删除用户
		 * @param userIds var userIds = id
		 ? [id]
		 : this.dataListSelections.map(item => {
				  return item.id
				})
		 * @returns {*}
		 */
		deleteUserInfo: (userIds: any) => {
			return request({
				url: serverContextPath + '/sys/user/delete',
				method: 'post',
				data: userIds
			})
		},

		/**
		 * 校验员工编号和用户名是否被占用
		 * @param staffId 员工编号
		 * @param username 用户名
		 * @returns {*}
		 */
		checkStaffId: (staffId: string, username: string) => {
			return request({
				url: serverContextPath + '/sys/user/checkStaffId/' + staffId + '/' + username,
				method: 'get',
			})
		},

		/**
		 * 校验员工编号是否被占用
		 * @param staffId
		 * @returns {*}
		 */
		checkStaffIdHas: (staffId: string) => {
			return request({
				url: serverContextPath + '/sys/user/checkStaffIdHas/' + staffId,
				method: 'get',
			})
		},

		/**
		 * 设置用户皮肤
		 * @param skin 皮肤 blue、dark
		 * @returns {*}
		 */
		setUserSkin: (skin: string) => {
			return request({
				url: serverContextPath + '/sys/user/setUserSkin/' + skin,
				method: 'get',
			})
		},

		/**
		 * 根据字典代码加载数据字典树结构
		 * @param classCode 字典代码，多个用逗号隔开
		 * @returns {*}
		 */
		getDicTreeByClassCode: (classCode: string) => {
			return request({
				url: serverContextPath + '/sys/dic/getDicTreeByClassCode/' + classCode,
				method: 'get',
			})
		},

		/**
		 *系统日志
		 * @param params
		 * {
		 * page: pageIndex,
		 * limit: pageSize,
		 * staff_name: this.dataForm.staff_name,
		 * username: this.dataForm.username,
		 * user_ip: this.dataForm.user_ip,
		 * oper_time_start: this.dataForm.oper_time_start,
		 * oper_time_end: this.dataForm.oper_time_end
		 * }
		 * @returns {Q.Promise<any> | Q.Promise<T | never> | never | PromiseLike<T | never> | Promise<T | never> | *}
		 */
		querySystemLog: (params: any) => {
			return request({
				url: serverContextPath + '/sys/log/list',
				method: 'get',
				params: params
			})
		},

		/**
		 * 获取消息配置数据列表
		 */
		queryMsgDefList: (params: any) => {
			return request({
				url: serverContextPath + '/sys/msgDef/list',
				method: 'post',
				data: params
			})
		},
		/**
		 * 根据id删除消息配置
		 */
		msgDefDeleteById: (ids: any) => {
			return request({
				url: serverContextPath + '/sys/msgDef/delete',
				method: 'post',
				data: ids
			})
		},
		/**
		 * 根据id查询消息信息
		 */
		msgDefInfoById: (ids: string) => {
			return request({
				url: serverContextPath + `/sys/msgDef/info/${ids}`,
				method: 'get',
			})
		},
		/**
		 * 保存消息配置
		*/
		saveMsgDef: (datas: any) => {
			return request({
				url: serverContextPath + `/sys/msgDef/save`,
				method: 'post',
				data: datas
			})
		},
		/**
		 * 修改消息配置
		 */
		updateMsgDef: (datas: any) => {
			return request({
				url: serverContextPath + `/sys/msgDef/update`,
				method: 'post',
				data: datas
			})
		},
		/**
		 * 消息发送历史数据列表
		 */
		queryMsgStreamList: (params: any) => {
			return request({
				url: serverContextPath + '/sys/msgStream/list',
				method: 'post',
				data: params
			})
		},
		/**
		 * 消息列表
		 */
		msgStreamQueryUndealMsg: (params: any) => {
			return request({
				url: serverContextPath + '/sys/msgStream/queryUndealMsg',
				method: 'post',
				data: params
			})
		},
		/**
		 * 消息标为已读
		 */
		setMsgStreamDeal: (ids: any) => {
			return request({
				url: serverContextPath + '/sys/msgStream/deal',
				method: 'post',
				data: ids
			})
		},
		/**
		 * 根据id查看消息详情
		 */
		msgStreamInfoById: (ids: any) => {
			return request({
				url: serverContextPath + `/sys/msgStream/info/${ids}`,
				method: 'get',
			})
		},
		/**
		 * hahah
		 */
		msgDefPageInfoById: (ids: string) => {
			return request({
				url: serverContextPath + `/sys/msgDef/pageInfo/${ids}`,
				method: 'get',
			})
		},

		/**
		 * 管理员重置用户密码
		 * @param userId 用户id
		 * @returns {*}
		 */
		resetPassword: (userId: string) => {
			return request({
				url: serverContextPath + `/sys/user/resetPassword/${userId}`,
				method: 'get',
			})
		},

		/**
		 * 根据条件查询下用户
		 * @param data 查询条件 可选条件包含 this.$http.adornData({
		 *                          id: '',
		 *                          username: '',
		 *                          accountName:'',
		 *                          status:'',
		 *                          isCouncil:'',
		 *                          isBussMng:'',
		 *                      })
		 * @returns {*}
		 */
		getUsersByParm: (data: any) => {
			return request({
				url: serverContextPath + '/sys/userAuth/getUser',
				method: 'post',
				data: data
			})
		},

		/**
		 * 查询角色
		 * @param params this.$http.adornParams({
				  page: this.pageIndex, 要请求的页
				  limit: this.pageSize, 每页条数
				  dataForm: this.dataForm 查询条件表单数据
				})
		 * @returns {Promise<*>} data.page
		 */
		queryRoleListPage: (params: any) => {
			return request({
				url: serverContextPath + '/sys/role/list',
				method: 'post',
				data: params
			})
		},

		/**
		 * 获取角色资源树
		 * @param id 角色id
		 * @returns {Promise<*>} data.tree 资源树，data.asingRes 选择节点
		 */
		getSysRoleResTree: (id: string) => {
			return request({
				url: serverContextPath + `/sys/role/getRoleResTree/${id}`,
				method: 'get',
			})
		},

		/**
		 * 根据id获取角色id
		 * @param id
		 * @returns {Promise<*>}
		 */
		getSysRoleInfo: (id: string) => {
			return request({
				url: serverContextPath + `/sys/role/info/${id}`,
				method: 'get',
			})
		},

		/**
		 * 新增角色
		 * @param data
		 * @returns {*}
		 */
		saveSysRoleInfo: (data: any) => {
			return request({
				url: serverContextPath + `/sys/role/save`,
				method: 'post',
				data: data
			})
		},

		/**
		 * 修改角色
		 * @param data
		 * @returns {*}
		 */
		updateSysRoleInfo: (data: any) => {
			return request({
				url: serverContextPath + `/sys/role/update`,
				method: 'post',
				data: data
			})
		},

		/**
		 * 删除角色
		 * @param data
		 * @returns {*}
		 */
		deleteSysRoleInfo: (data: any) => {
			return request({
				url: serverContextPath + `/sys/role/delete`,
				method: 'post',
				data: data
			})
		},

		/**
		 * 设置角色资源
		 * @param id 角色id
		 * @param resId 资源id数组
		 * @returns {*}
		 */
		setSysRoleMenu: (id: any, resId: any) => {
			return request({
				url: serverContextPath + `/sys/role/setRoleMenu`,
				method: 'post',
				data: {
					'id': id,
					'resId': resId
				}
			})
		},

		/**
		 * 根据角色id获取对应用户
		 * @param params this.$http.adornParams({
					'page': pageIndex,
					'limit': pageSize,
					'roleId': id
				  })
		 * @returns {Promise<*>}
		 */
		getSysRoleUserList: (params: any) => {
			return request({
				url: serverContextPath + `/sys/role/roleUserList`,
				method: 'get',
				params: params
			})
		},

		/**
		 * 租户下角色资源权限，只能选择租户下的资源范围
		 * @param {租户id} tenantId 
		 * @param {角色id} id 角色id决定是否有选中
		 */
		resetTenantRoleResTree: (tenantId:string, id:any) => {
			return request({
				url: serverContextPath + `/sys/role/resetTenantRoleResTree/${tenantId}/${id}`,
				method: 'get',
			})
		},

		/**
		 * 获取委托、受托的有效用户，不包含员工及已添加的用户
		 * @param params this.$http.adornParams({
					'page': pageIndex,
					'limit': pageSize,
					'roleId': id
				})
		* @returns {Promise<*>}
		*/
		getRoleUserNoChooseList: (params: any) => {
			return request({
				url: serverContextPath + `/sys/role/roleUserNoChooseList`,
				method: 'post',
				data: params
			})
		},

		/**
		 * 设置角色资源
		 * @param userId 用户id
		 * @param roleId 角色id
		 * @returns {*}
		 */
		setSysRoleUser: (userId: any, roleId: any) => {
			return request({
				url: serverContextPath + `/sys/role/setSysRoleUser`,
				method: 'post',
				data: {
					'userId': userId,
					'roleId': roleId
				}
			})
		},

		/**
		 * 删除用户角色关联
		 * @param id
		 * @returns {*}
		 */
		deleteSysRoleUser: (id: any) => {
			return request({
				url: serverContextPath + `/sys/role/deleteSysRoleUser`,
				method: 'post',
				data: {
					'id': id
				}
			})
		},

		/**
		 * 统一身份认证登录接口
		 * @param iamCode 统一身份认证返回的授权码
		 * @param terminal 终端类型 1-受托PC，3-委托PC
		 * @returns {*}
		 */
		iamLogin: (iamCode: string, terminal: string) => {
			return request({
				url: serverContextPath + '/sys/login/iamLogin',
				method: 'post',
				data: {
					'iamCode': iamCode,
					'terminal': terminal
				}
			})
		},

		/**
		 * 查询菜单资源树
		 * @param params this.$http.adornParams({terminals:{1,2,3...}})
		 * @returns {Promise<*>} data.resTree
		 */
		getResByTerminal: (params: any) => {
			return request({
				url: serverContextPath + '/sys/menu/getResByTerminal',
				method: 'get',
				params: params
			})
		},

		/**
		 * 查询菜单资源树，禁用非末级节点
		 * @param params this.$http.adornParams({terminals:{1,2,3...}})
		 * @returns {Promise<*>} data.resTree
		 */
		getResByTerminalDisableParent: (params: any) => {
			return request({
				url: serverContextPath + '/sys/menu/getResByTerminalDisableParent',
				method: 'get',
				params: params
			})
		},

		/**
		 * 资源维度查询权限（岗位）
		 * @param ids
		 * @param pType
		 * @returns {*}
		 */
		getResPermissionByKeys: (ids: any, pType: number) => {
			if (pType === 1) {
				return request({
					url: serverContextPath + `/sys/menu/getPermissionStationByRes`,
					method: 'post',
					data: {
						'ids': ids
					}
				})
			} else {
				return request({
					url: serverContextPath + `/sys/menu/getPermissionUserByRes`,
					method: 'post',
					data: {
						'ids': ids
					}
				})
			}
		},

		/**
		 * 获取终端数据
		 * @param params
		 * @returns {Promise|Q.Promise<any>|Q.Promise<T | never>|*|never|PromiseLike<T | never>|Promise<T | never>}
		 */
		getTenantList: (params: any) => {
			return request({
				url: serverContextPath + '/sys/tenant/list',
				method: 'post',
				data: params
			})
		},

		/**
		 * 根据id获取终端信息
		 * @param id
		 * @returns {*}
		 */
		getTenantInfo: (id: string) => {
			return request({
				url: serverContextPath + `/sys/tenant/info/${id}`,
				method: 'get'
			})
		},

		/**
		 *  保存租户信息
		 * @param data
		 * @returns {*}
		 */
		saveTenantInfo: (data: any) => {
			return request({
				url: serverContextPath + `/sys/tenant/save`,
				method: 'post',
				data: data
			})
		},

		/**
		 *  保存租户信息
		 * @param data
		 * @returns {*}
		 */
		updateTenantInfo: (data: any) => {
			return request({
				url: serverContextPath + `/sys/tenant/update`,
				method: 'post',
				data: data
			})
		},

		/**
		 * 删除租户
		 * @param ids 选中的id数组 var ids = id ? [id] : this.dataListSelections.map(item => {
				  return item.id
				})
		 * @returns {Promise<*>}
		 */
		deleteTenantInfo: (ids: any) => {
			return request({
				url: serverContextPath + '/sys/tenant/delete',
				method: 'post',
				data: ids
			})
		},

		/**
		 * 获取可用租户信息
		 * @returns {*}
		 */
		getTenantSelect: () => {
			return request({
				url: serverContextPath + `/sys/tenant/getTenantSelect`,
				method: 'get'
			})
		},

		/**
		 * 获取租户资源树
		 * @param id 角色id
		 * @returns {Promise<*>} data.tree 资源树，data.asingRes 选择节点
		 */
		getSysTenantResTree: async (id: string) => {
			return request({
				url: serverContextPath + `/sys/tenant/getSysTenantResTree/${id}`,
				method: 'get',
			})
		},

		/**
		 * 设置租户资源
		 * @param id 角色id
		 * @param resId 资源id数组
		 * @returns {*}
		 */
		setSysTenantMenu: (id:string, resId: any) => {
			return request({
				url: serverContextPath + `/sys/tenant/setSysTenantMenu`,
				method: 'post',
				data: {
					'id': id,
					'resId': resId
				}
			})
		},

		/**
		 * 锁屏解锁
		 * @param username 用户名
		 * @param passwd 密码
		 * @param uuid ''
		 * @param captcha ''
		 * @param terminal 终端
		 * @returns {*}
		 */
		unlock: (username: string, passwd: string, uuid: string, captcha: string, terminal: string) => {
			return request({
				url: serverContextPath + '/sys/login/unblock',
				method: 'post',
				data: {
					username,
					passwd,
					uuid,
					captcha,
					terminal
				}
			})
		},

		/**
		 * 参数管理分页查询
		 * @returns {*}
		 */
		getConfigList: (params: any) => {
			return request({
				url: serverContextPath + `/sys/config/list`,
				method: 'post',
				data: params
			})
		},

		/**
		 * 删除参数配置
		 * @param {*} ids 
		 */
		deleteConfig: (ids: any) => {
			return request({
				url: serverContextPath + '/sys/config/delete',
				method: 'post',
				data: ids
			})
		},

		/**
		 * 根据id查询参数配置信息
		 * @param {*} id 
		 */
		getConfigInfo: (id: any) => {
			return request({
				url: serverContextPath + `/sys/config/info/${id}`,
				method: 'get'
			})
		},

		/**
		 *  保存租户信息
		 * @param data
		 * @returns {*}
		 */
		saveConfigInfo: (data: any) => {
			return request({
				url: serverContextPath + `/sys/config/save`,
				method: 'post',
				data: data
			})
		},

		/**
		 *  保存租户信息
		 * @param data
		 * @returns {*}
		 */
		updateConfigInfo: (data: any) => {
			return request({
				url: serverContextPath + `/sys/config/update`,
				method: 'post',
				data: data
			})
		},

		/**
		 * 比较通用的用户查询，只查当前租户的，查询条件为部门名称和姓名
		 * @param userParam 
		 */
		queryUserSkiving: (userParam: any) => {
			return request({
				url: serverContextPath + `/sys/userAuth/queryUserSkiving`,
				method: 'get',
				params: userParam
			})
		},

		/**
		 * 分页查询表单设计列表
		 * @param params 
		 * @returns 
		 */
		queryFormDesignerList: (params: any) => {
			return request({
				url: serverContextPath + `/sys/formDesigner/list`,
				method: 'post',
				data: params
			})
		},

		/**
		 * 根据编号取表单设计数据
		 * @param formCode 
		 * @returns 
		 */
		getFormDesignerByClassCode: (formCode: string) => {
			return request({
				url: serverContextPath + '/sys/formDesigner/getFormJsonByCode/' + formCode,
				method: 'get',
			})
		},
		/**
		 * 根据id获取表单设计数据
		 * @param id 
		 * @returns 
		 */
		getFormDesignerById: (id: string) => {
			return request({
				url: serverContextPath + '/sys/formDesigner/info/' + id,
				method: 'get',
			})
		},
		/**
		 * 保存表单设计数据
		 * @param data 
		 * @returns 
		 */
		saveFormDesigner: (data: any) => {
			return request({
				url: serverContextPath + '/sys/formDesigner/save',
				method: 'post',
				data: data
			})
		},
		/**
		 * 修改表单设计数据
		 * @param data 
		* @returns {Promise<*>}
		*/
		updateFormDesigner: (data: any) => {
			return request({
				url: serverContextPath + '/sys/formDesigner/update',
				method: 'post',
				data: data
			})
		},

		/**
		 * 删除表单设计数据
		 * @param ids 选中的id数组 var ids = id ? [id] : this.dataListSelections.map(item => {
				 return item.id
				})
		* @returns {Promise<*>}
		*/
		deleteFormDesigner: (ids: string[]) => {
			return request({
				url: serverContextPath + '/sys/formDesigner/delete',
				method: 'post',
				data: ids
			})
		},
		/**
		 * 获取表单设计所有数据
		 */
		getFormDesignerList: () => {
			return request({
				url: serverContextPath + `/sys/formDesigner/getFormDesignerList`,
				method: 'get'
			})
		},
		/**
		 * 分页查询业务类型分类
		 * @param params 
		 * @returns 
		 */
		queryBusinessTypeList: (params: any) => {
			return request({
				url: serverContextPath + `/sys/businessType/list`,
				method: 'post',
				data: params
			})
		},

		/**
		 * 根据id获取业务类型分类
		 * @param id 
		 * @returns 
		 */
		getBusinessTypeById: (id: string) => {
			return request({
				url: serverContextPath + '/sys/businessType/info/' + id,
				method: 'get',
			})
		},
		/**
		 * 保存业务类型分类
		 * @param data 
		 * @returns 
		 */
		saveBusinessType: (data: any) => {
			return request({
				url: serverContextPath + '/sys/businessType/save',
				method: 'post',
				data: data
			})
		},
		/**
		 * 修改业务类型分类
		 * @param data 
		* @returns {Promise<*>}
		*/
		updateBusinessType: (data: any) => {
			return request({
				url: serverContextPath + '/sys/businessType/update',
				method: 'post',
				data: data
			})
		},

		/**
		 * 删除业务类型分类
		 * @param ids 选中的id数组 var ids = id ? [id] : this.dataListSelections.map(item => {
				 return item.id
				})
		* @returns {Promise<*>}
		*/
		deleteBusinessType: (ids: string[]) => {
			return request({
				url: serverContextPath + '/sys/businessType/delete',
				method: 'post',
				data: ids
			})
		},
		/**
		 * 获取业务类型所有数据
		 * @returns 
		 */
		getBusinessTypeList: () => {
			return request({
				url: serverContextPath + '/sys/businessType/getBusinessTypeList/',
				method: 'get',
			})
		},
		/**
		 * 分页应用设计
		 * @param params 
		 * @returns 
		 */
		queryBusinessDesignerList: (params: any) => {
			return request({
				url: serverContextPath + `/sys/businessDesigner/list`,
				method: 'post',
				data: params
			})
		},

		/**
		 * 根据id获取应用设计数据
		 * @param id 
		 * @returns 
		 */
		getBusinessDesignerById: (id: string) => {
			return request({
				url: serverContextPath + '/sys/businessDesigner/info/' + id,
				method: 'get',
			})
		},
		/**
		 * 保存应用设计数据
		 * @param data 
		 * @returns 
		 */
		saveBusinessDesigner: (data: any) => {
			return request({
				url: serverContextPath + '/sys/businessDesigner/save',
				method: 'post',
				data: data
			})
		},
		/**
		 * 修改应用设计数据
		 * @param data 
		* @returns {Promise<*>}
		*/
		updateBusinessDesigner: (data: any) => {
			return request({
				url: serverContextPath + '/sys/businessDesigner/update',
				method: 'post',
				data: data
			})
		},

		/**
		 * 删除应用设计数据
		 * @param ids 选中的id数组 var ids = id ? [id] : this.dataListSelections.map(item => {
				 return item.id
				})
		* @returns {Promise<*>}
		*/
		deleteBusinessDesigner: (ids: string[]) => {
			return request({
				url: serverContextPath + '/sys/businessDesigner/delete',
				method: 'post',
				data: ids
			})
		},
		/**
		 * 根据设计编码获取新增表单的设计json
		 * @param designerCode 
		 * @returns 
		 */
		getFormJsonAddByBusDesignerCode: (designerCode: string) => {
			return request({
				url: serverContextPath + '/sys/businessDesigner/getFormJsonAddByBusDesignerCode/' + designerCode,
				method: 'get',
			})
		},
		/**
		 * 根据设计编码获取包含表单json的设计
		 * @param designerCode 
		 * @returns 
		 */
		getSysBusinessDesignerByCodeHasJson: (designerCode: string) => {
			return request({
				url: serverContextPath + '/sys/businessDesigner/getSysBusinessDesignerByCodeHasJson/' + designerCode,
				method: 'get',
			})
		},
		/**
		 * 通用业务表单新增提交方法，采用json存储表单数据，如果挂接了流程则会在业务提交后发起流程
		 * @param data 
		 * @returns 
		 */
		submitBusinessCommonAdd: (data: any) => {
			return request({
				url: serverContextPath + '/sys/businessCommon/submitBusinessCommonAdd',
				method: 'post',
				data: data
			})
		},

		/**
		 * 根据id获取业务数据
		 * @param id 
		 * @returns 
		 */
		getBusinessCommonById: (id: string) => {
			return request({
				url: serverContextPath + '/sys/businessCommon/info/' + id,
				method: 'get',
			})
		},
		/**
		 * 通用业务表单新增提交方法，采用json存储表单数据，如果挂接了流程则会在业务提交后发起流程
		 * @param data 
		 * @returns 
		 */
		submitBusinessCommonUpdate: (data: any) => {
			return request({
				url: serverContextPath + '/sys/businessCommon/submitBusinessCommonUpdate',
				method: 'post',
				data: data
			})
		}
	}
}